Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add eachIndex/forEachIndex function with tests #264

Closed
wants to merge 3 commits into from
Closed

add eachIndex/forEachIndex function with tests #264

wants to merge 3 commits into from

Conversation

kadishmal
Copy link

I've added a new function eachIndex with forEachIndex alias that does exactly what each function does. The difference is in the number of arguments the iterators accept.

function eachIterator(val, callback) {...}
function eachIndexIterator(val, index, callback) {...}

The iterator for eachIndex accepts additional index argument which indicates on the index in the array that val is.

This functionality was necessary for me when I needed to distinguish the values of the supplied array based on their position in the array.

I hope this function will be useful for others as well.

@brianmaissy
Copy link
Contributor

This and #168 seem to be duplicates of each other

@kadishmal
Copy link
Author

As I see forEachOf is applicable for Objects while eachIndex is for Arrays which async natively works with. I see a way to merge these two functionalities, though.

@brianmaissy
Copy link
Contributor

In the discussion there it is proposed to have forEachOf support both objects and arrays

@kadishmal
Copy link
Author

Any plans to accept forEachOf?

@brianmaissy
Copy link
Contributor

Thats a good question. @caolan, whats the status of that? I think the last activity there was @dominicbarnes asked you to review a partial implementation.

@nathanaschbacher
Copy link

What's the status of this being merged into master? And why have several other requests for the same feature been incorrectly closed as being duplicates of an issue that's asking for iterating over object properties, not providing the index in an array that the item sent to the iterator came from?

@caolan
Copy link
Owner

caolan commented Mar 28, 2014

closing in preference of forEachOf

@caolan caolan closed this Mar 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants